<template>
  <div id="userLayout" :class="['user-layout-wrapper', device, className]">
    <div class="container">
      <div class="top">
        <img src="~@/assets/login/header-img.png" class="header-img" :alt="systemName" @click="goToLogin">
      </div>

      <div class="login-container">
        <div class="login-box">
          <div class="login-title" :data-content="systemName">
            {{ systemName }}
          </div>
          <div class="login-main">
            <route-view></route-view>
          </div>
        </div>
      </div>

      <div class="login-menu-container">
        <LoginMenu />
      </div>

      <div class="footer">
        <div class="links">
          <!-- <a href="http://doc.jeecg.com" target="_blank">帮助</a>
          <a href="https://github.com/zhangdaiscott/jeecg-boot" target="_blank">隐私</a>
          <a href="https://github.com/zhangdaiscott/jeecg-boot/blob/master/LICENSE" target="_blank">条款</a> -->
        </div>
        <div class="copyright">
          <!-- Copyright &copy; 2019 <a href="http://www.jeecg.com" target="_blank">JEECG开源社区</a> 出品 -->
          Copyright &copy; {{ year }} {{ footText }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import RouteView from "@/components/layouts/RouteView"
  import { mixinDevice } from '@/utils/mixin.js'
  import config from '@/defaultSettings'
  import LoginMenu from '@/components/loginMenu'

  export default {
    name: "UserLayout",
    components: { RouteView, LoginMenu },
    mixins: [mixinDevice],
    data () {
      return {
        systemName: '',
        className: '',
        systemArr: config.systemArr,
        footText: config.footText,
        year: new Date().getFullYear()
      }
    },
    mounted () {
      document.body.classList.add('userLayout')
      this.initData()
    },
    watch:{
      "$route":function(to,from){
        this.initData()
      }
    },
    methods: {
      initData() {
        const routerName = this.$route.params.systemName
        this.className = routerName + '-bg'
        const system = this.systemArr.find(item => item.router === routerName)
        if (system) this.systemName = system.name

        this.$ls.set('loginSystemPath', this.$route.fullPath)
      },
      goToLogin() {
        this.$router.push('/user/login')
      }
    },
    beforeDestroy () {
      document.body.classList.remove('userLayout')
    },
  }
</script>

<style lang="less" scoped>
  #userLayout.user-layout-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    min-width: 1200px;
    min-height: 600px;
    // background: #07112c url('~@/assets/login/bg.png') no-repeat;
    background-size: cover;
    background-position: center center;

    &.mapIntegration-bg {
      background: #07112c url('~@/assets/login/mapIntegration-bg.png') no-repeat;
    }

    &.bigDataVisualization-bg {
      background: #07112c url('~@/assets/login/bigDataVisualization-bg.png') no-repeat;
    }

    &.leaderCockpit-bg {
      background: #07112c url('~@/assets/login/leaderCockpit-bg.png') no-repeat;
    }

    &.unifiedUserManagement-bg {
      background: #07112c url('~@/assets/login/unifiedUserManagement-bg.png') no-repeat;
    }

    &.eventFlow-bg {
      background: #07112c url('~@/assets/login/eventFlow-bg.png') no-repeat;
    }

    &.officeAutomation-bg {
      background: #07112c url('~@/assets/login/officeAutomation-bg.png') no-repeat;
    }

    @font-face {
      font-family: 'fzzykgb10';
      src: url('~@/assets/fonts/fzzykgb10.ttf');
    }

    &.mobile {
      .container {
        .main {
          max-width: 368px;
          width: 98%;
        }
      }
    }

    .container {
      width: 100%;
      min-height: 100%;
      // background: #f0f2f5 url(~@/assets/background.svg) no-repeat 50%;
      background-size: 100%;
      // padding: 110px 0 144px;
      position: relative;

      a {
        text-decoration: none;
      }

      .top {
        text-align: center;

        .header {
          height: 44px;
          line-height: 44px;

          .badge {
            position: absolute;
            display: inline-block;
            line-height: 1;
            vertical-align: middle;
            margin-left: -12px;
            margin-top: -10px;
            opacity: 0.8;
          }

          .logo {
            height: 44px;
            vertical-align: top;
            margin-right: 16px;
            border-style: none;
          }

          .title {
            font-size: 33px;
            color: rgba(0, 0, 0, .85);
            font-family: "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
            font-weight: 600;
            position: relative;
            top: 2px;
          }
        }
        .desc {
          font-size: 14px;
          color: rgba(0, 0, 0, 0.45);
          margin-top: 12px;
          margin-bottom: 40px;
        }

        .header-img {
          min-width: 420px;
          width: 30vw;
          margin-top: 5vh;
          cursor: pointer;

          @media (max-height: 700px) {
            & {
              margin-top: 2vh;
            }
          }
        }
      }

      .login-container {
        position: absolute;
        top: 0;
        min-width: 400px;
        width: 25%;
        height: 100%;
        right: 16vw;
        display: flex;
        align-items:center;
        justify-content:center;

        // @media (max-width: 1400px) {
        //   & {
        //     right: 16vw;
        //   }
        // }

        .login-box {
            width: 100%;
            // min-height: 500px;
            // margin-top: -5vh;

          .login-title {
            position: relative;
            font-family: 'fzzykgb10';
            text-align: center;
            font-size: 42px;
            font-style: italic;
            color: #36bef1;
            // background: linear-gradient(0deg, #36bef1 0%, #dbfdfe 100%);
            // -webkit-background-clip: text;
            // -webkit-text-fill-color: transparent;
            margin-bottom: 20px;

            &[data-content]::after {
              content:attr(data-content);
              width: 100%;
              text-align: center;
              display: block;
              position:absolute;
              color:#dbfdfe;
              left:0;
              top:0;
              z-index:2;
              -webkit-mask-image:-webkit-gradient(linear, 0 0, 0 bottom, from(#dbfdfe), to(rgba(54,190,241,0)));
            }
          }

          .login-main {
            overflow: hidden;
            // margin-top: 20px;
            background-color: rgba(55, 138, 202, .16);
            border-radius: 4px;
            padding: 10px 40px 0 40px;
          }
        }
      }

      .login-menu-container {
        position: absolute;
        width: 150px;
        height: 100%;
        top: 0;
        right: 1.77vw;
        display: flex;
        align-items:center;
        justify-content:center;
      }

      .main {
        // min-width: 260px;
        // width: 368px;
        // margin: 0 auto;
      }

      .footer {
        position: absolute;
        width: 100%;
        bottom: 0;
        padding: 0 16px;
        margin: 48px 0 24px;
        text-align: center;

        .links {
          margin-bottom: 8px;
          font-size: 14px;
          a {
            color: rgba(0, 0, 0, 0.45);
            transition: all 0.3s;
            &:not(:last-child) {
              margin-right: 40px;
            }
          }
        }
        .copyright {
          color: #ffffff;
          font-size: 14px;
        }
      }
    }
  }
</style>